package model.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

import model.dto.DTOCategory;
import model.service.CategoryService;
import utilities.ConnectionManagement;

public class DAOCategory implements CategoryService{

	private Connection con;
	
	public DAOCategory(){
		con = new ConnectionManagement().getConnection();
	}
	@Override
	
	public boolean addCategory(DTOCategory category) {
		String sql = "INSERT INTO tblcategories(category_id, category_name) VALUES(nextval('category'),?)";
		try(
			PreparedStatement pstmt = con.prepareStatement(sql);
		){
			pstmt.setString(1,category.getName());
			pstmt.executeUpdate();
			return true;
		}catch(SQLException ex){
			System.out.println("Add Category Error: ");
			ex.printStackTrace();
		}
		return false;
	}

	@Override
	public boolean removeCategory(Integer id) {
		return false;
	}

	@Override
	public List<DTOCategory> listCategory() {
		return null;
	}

	@Override
	public List<DTOCategory> listCategory(DTOCategory category) {
		// TODO Auto-generated method stub
		return null;
	}
	
	
}
